#include "cpp_story.h"
#include <vector>

struct Context
{
    int total;
    std::vector<int> values;
};

STEP_DEF("value with table")
{
    CONTEXT(Context, c);
    USING_TABLE(t);
    for (int row = 0; row < t->get_row_count(); row++)
        c->values.push_back(atoi(t->get_data(row, 0).c_str()));
    return true;
}

STEP_DEF("add value")
{
    CONTEXT(Context, c);
    std::vector<int>::iterator iter;
    c->total = 0;
    for (iter = c->values.begin(); iter != c->values.end(); ++iter)
        c->total += *iter;
    return true;
}

STEP_DEF("result is equal to (.*)")
{
    CONTEXT(Context, c);
    REGEX_INT(total);

    CHECK_EQUAL(total, c->total);

    return true;
}

